package com.yc.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yc.domain.User;
import com.yc.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Title:<br>
 * Description: <br>
 * Author:陈圆(chenyuan@bosssoft.com.cn) <br>
 * Date:2020/9/24
 */
@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;

    public User findUser(String id) {
        return userMapper.selectUser(id);
    }

    public PageInfo selectList(Integer pageNum, Integer pageSize){
        PageHelper.startPage(pageNum, pageSize); // 设定当前页码，以及当前页显示的条数
        //PageHelper.offsetPage(pageNum, pageSize);也可以使用此方式进行设置
        List<User> list = userMapper.listUsers();
        PageInfo<User> pageInfo = new PageInfo<User>(list);
        return pageInfo;
    }

    public String insertUser(User user){
        userMapper.insertUser(user);
        return "成功";
    }
}
